﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Maticsoft.DBUtility;
using System.Data.SqlClient;

namespace ElingOA6_Admin_DSJCJ.DAL
{
    /// <summary>
    /// 信息类别数据类
    /// </summary>
    public class DocCls
    {
        /// <summary>
        /// 获得数据列表,根据公司编号,根据排序字段排序 FIsUse=1
        /// <creator>wangl</creator>
        /// <date>2013-07-22</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <returns>信息类别列表</returns>
        public DataSet GetListByEntityNo(string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT FEntityNo,FDocClsCd,FPreDocClsCd,FDocClsProp,FDocClsName,FIsUse,FUseSubTitle,FIsPicNews,FPicHeight,FPicWidth,FIsPicWaterMark,FWaterMarkCls,FIsHomePageShowLimit,FHomePageShowDays,FEditMode,FDefaultEditMode,FIsNeedAudit,FIsShowHomePageCtrl,FDefaultShowValue,FIsPublicTitle,FIsCtrlLookAuthority,FIsReferenceNo,FIsNotice,FIsRecObject,FIsMeeting,FWaterMarkPos,FIsIndex,FLeftRightMargin,FTopBottomMargin,FLogoOldFileName,FLogoNewFileName,FLogoImage,FDocClsHomepage,FCreateDate,FIsImport,FSeq,FIsPubJCMS,FJCMSColID,FClsTemplID,FTemplTopPicPath,FIsExamine,FIsManuscript FROM t_docCls ");
            strSql.Append(" WHERE FEntityNo=@FEntityNo and FIsUse=1");
            strSql.Append(" ORDER BY FSeq,FDocClsCd");
            SqlParameter[] parameters = { 
                 new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)
                                        };
            parameters[0].Value = entityNo;
            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }
        /// 获得数据列表,根据公司编号,根据排序字段排序(已启用的栏目)
        /// <creator>sunlj</creator>
        /// <date>2015-01-26</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <returns>信息类别列表</returns>
        public DataSet GetListIsUseByEntityNo(string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT FEntityNo,FDocClsCd,FPreDocClsCd,FDocClsProp,FDocClsName,FIsUse,FUseSubTitle,FIsPicNews,FPicHeight,FPicWidth,FIsPicWaterMark,FWaterMarkCls,FIsHomePageShowLimit,FHomePageShowDays,FEditMode,FDefaultEditMode,FIsNeedAudit,FIsShowHomePageCtrl,FDefaultShowValue,FIsPublicTitle,FIsCtrlLookAuthority,FIsReferenceNo,FIsNotice,FIsRecObject,FIsMeeting,FWaterMarkPos,FIsIndex,FLeftRightMargin,FTopBottomMargin,FLogoOldFileName,FLogoNewFileName,FLogoImage,FDocClsHomepage,FCreateDate,FIsImport,FSeq,FIsPubJCMS,FJCMSColID,FClsTemplID,FTemplTopPicPath,FIsExamine,FIsManuscript FROM t_docCls ");
            strSql.Append(" WHERE FEntityNo=@FEntityNo");
            strSql.Append(" AND FIsUse=1");
            strSql.Append(" ORDER BY FSeq,FDocClsCd");
            SqlParameter[] parameters = { 
                 new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)
                                        };
            parameters[0].Value = entityNo;
            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 获得数据列表,根据公司编号,根据排序字段排序(全部数据)
        /// <creator>wangl</creator>
        /// <date>2013-08-09</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <returns>信息类别列表</returns>
        public DataSet GetListAllByEntityNo(string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT FEntityNo,FDocClsCd,FPreDocClsCd,FDocClsProp,FDocClsName,FIsUse,FUseSubTitle,FIsPicNews,FPicHeight,FPicWidth,FIsPicWaterMark,FWaterMarkCls,FIsHomePageShowLimit,FHomePageShowDays,FEditMode,FDefaultEditMode,FIsNeedAudit,FIsShowHomePageCtrl,FDefaultShowValue,FIsPublicTitle,FIsCtrlLookAuthority,FIsReferenceNo,FIsNotice,FIsRecObject,FIsMeeting,FWaterMarkPos,FIsIndex,FLeftRightMargin,FTopBottomMargin,FLogoOldFileName,FLogoNewFileName,FLogoImage,FDocClsHomepage,FCreateDate,FIsImport,FSeq,FIsPubJCMS,FJCMSColID,FClsTemplID,FTemplTopPicPath,FIsExamine,FIsManuscript FROM t_docCls ");
            strSql.Append(" WHERE FEntityNo=@FEntityNo");
            strSql.Append(" ORDER BY FSeq,FDocClsCd");
            SqlParameter[] parameters = { 
                 new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)
                                        };
            parameters[0].Value = entityNo;
            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 获得数据列表,可以推送到JCMS
        /// <creator>wangl</creator>
        /// <date>2013-11-20</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <returns>信息类别列表</returns>
        public DataSet GetListIsJcmsByEntityNo(string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT FEntityNo,FDocClsCd,FPreDocClsCd,FDocClsName,FSeq FROM fn_GetJcmsDocClsByCTE(@FEntityNo) ");
            strSql.Append(" ORDER BY FSeq,FDocClsCd");
            SqlParameter[] parameters = { 
                 new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)
                                        };
            parameters[0].Value = entityNo;
            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 根据用户权限获取树目录
        /// <creator>wangl</creator>
        /// <date>2013-08-05</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="empNo">员工编号</param>
        /// <param name="deptNo">部门编号</param>
        /// <param name="authority">权限</param>
        /// <returns></returns>
        public DataSet GetListByAuthority(string entityNo, string empNo, string deptNo, string authority)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Fdocclscd,fpredocclscd,fdocclsprop,fdocclsname,fisauthority,FSeq from dbo.fn_GetDocClsByAuthority(");
            strSql.Append(" @FEntityNo,@FDeptNo,@FEmplNo,@FAuthorityType)");

            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FAuthorityType", SqlDbType.NVarChar,10),
                    new SqlParameter("@FEmplNo", SqlDbType.NVarChar,15),
                    new SqlParameter("@FDeptNo",SqlDbType.NVarChar,12)};
            parameters[0].Value = entityNo;
            parameters[1].Value = authority;
            parameters[2].Value = empNo;
            parameters[3].Value = deptNo;

            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 特定栏目是否有特定的权限
        /// 修改 by wangl 2014-09-23 select COUNT(*) from dbo.fn_GetDocClsByAuthority
        /// <creator>wangl</creator>
        /// <date>2013-08-06</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="empNo">员工编号</param>
        /// <param name="deptNo">部门编号</param>
        /// <param name="authority">权限</param>
        /// <param name="docClsNo">信息类别编号</param>
        /// <returns></returns>
        public bool ExistsAuthorityDocClsNo(string entityNo, string empNo, string deptNo, string authority, string docClsNo)
        {
            StringBuilder strSql = new StringBuilder();
            //strSql.Append("select top 1 Fdocclscd,fpredocclscd,fdocclsprop,fdocclsname,fisauthority from dbo.fn_GetDocClsByAuthority(");
            strSql.Append("select COUNT(*) from dbo.fn_GetDocClsByAuthority(");
            strSql.Append(" @FEntityNo,@FDeptNo,@FEmplNo,@FAuthorityType)");
            strSql.Append(" WHERE FDocClsCd=@FDocClsCd");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FAuthorityType", SqlDbType.NVarChar,10),
                    new SqlParameter("@FEmplNo", SqlDbType.NVarChar,15),
                    new SqlParameter("@FDeptNo",SqlDbType.NVarChar,12),
                     new SqlParameter("@FDocClsCd",SqlDbType.VarChar,25)                    
                                        };
            parameters[0].Value = entityNo;
            parameters[1].Value = authority;
            parameters[2].Value = empNo;
            parameters[3].Value = deptNo;
            parameters[4].Value = docClsNo;
            if (DbHelperSQL.Exists(strSql.ToString(), parameters))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 得到一个对象
        /// <creator>wangl</creator>
        /// <date>2013-07-23</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docClsCd">信息类别编号</param>
        /// <returns></returns>
        public Model.DocCls GetModel(string entityNo, string docClsCd)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT FEntityNo,FDocClsCd,FPreDocClsCd,FDocClsProp,FDocClsName,FIsUse,FUseSubTitle,FIsPicNews,FPicHeight,FPicWidth,FIsPicWaterMark,FWaterMarkCls,FIsHomePageShowLimit,FHomePageShowDays,FEditMode,FDefaultEditMode,FIsNeedAudit,FIsShowHomePageCtrl,FDefaultShowValue,FIsPublicTitle,FIsCtrlLookAuthority,FIsReferenceNo,FIsNotice,FIsRecObject,FIsMeeting,FWaterMarkPos,FIsIndex,FLeftRightMargin,FTopBottomMargin,FLogoOldFileName,FLogoNewFileName,FLogoImage,FDocClsHomepage,FCreateDate,FIsImport,FSeq,FIsPubJCMS,FJCMSColID,FClsTemplID,FTemplTopPicPath,FIsExamine,FIsManuscript,FIsSpecialTopic,FIsVote,FLookAuthorityMode FROM t_docCls ");
            strSql.Append(" where FEntityNo=@FEntityNo and FDocClsCd=@FDocClsCd");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,50),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,50)
                                        };
            parameters[0].Value = entityNo;
            parameters[1].Value = docClsCd;

            Model.DocCls model = new Model.DocCls();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 获取下一级目录的个数
        /// <creator>wangl</creator>
        /// <date>2013-07-23</date>
        /// </summary>
        /// <param name="docClsCd">信息栏目编号</param>
        /// <param name="entityNo">公司编号</param>
        /// <returns>下级目录数量</returns>
        public int GetChildeCount(string docClsCd, string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(" select count(*) from t_docCls ");
            strSql.Append(" where FPreDocClsCd=@FPreDocClsCd and FEntityNo=@FEntityNo and  FIsUse='1' ");

            SqlParameter[] parameters = {
					new SqlParameter("@FPreDocClsCd", SqlDbType.NVarChar,12),
                    new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12)};

            parameters[0].Value = docClsCd;
            parameters[1].Value = entityNo;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (null != obj)
            {
                return int.Parse(obj.ToString());
            }
            else
            {
                return 0;
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// <creator>wangl</creator>
        /// <date>2013-07-22</date> 
        /// </summary>
        /// <param name="row">数据行</param>
        /// <returns>信息类别实体</returns>
        public ElingOA6_Admin_DSJCJ.Model.DocCls DataRowToModel(DataRow row)
        {
            ElingOA6_Admin_DSJCJ.Model.DocCls model = new ElingOA6_Admin_DSJCJ.Model.DocCls();
            if (row != null)
            {
                if (row["FEntityNo"] != null)
                {
                    model.FEntityNo = row["FEntityNo"].ToString();
                }
                if (row["FDocClsCd"] != null)
                {
                    model.FDocClsCd = row["FDocClsCd"].ToString();
                }
                if (row["FPreDocClsCd"] != null)
                {
                    model.FPreDocClsCd = row["FPreDocClsCd"].ToString();
                }
                if (row["FDocClsProp"] != null)
                {
                    model.FDocClsProp = row["FDocClsProp"].ToString();
                }
                if (row["FDocClsName"] != null)
                {
                    model.FDocClsName = row["FDocClsName"].ToString();
                }
                if (row["FIsUse"] != null && row["FIsUse"].ToString() != "")
                {
                    model.FIsUse = int.Parse(row["FIsUse"].ToString());
                }
                if (row["FUseSubTitle"] != null && row["FUseSubTitle"].ToString() != "")
                {
                    model.FUseSubTitle = int.Parse(row["FUseSubTitle"].ToString());
                }
                if (row["FIsPicNews"] != null && row["FIsPicNews"].ToString() != "")
                {
                    model.FIsPicNews = decimal.Parse(row["FIsPicNews"].ToString());
                }
                if (row["FPicHeight"] != null && row["FPicHeight"].ToString() != "")
                {
                    model.FPicHeight = int.Parse(row["FPicHeight"].ToString());
                }
                if (row["FPicWidth"] != null && row["FPicWidth"].ToString() != "")
                {
                    model.FPicWidth = int.Parse(row["FPicWidth"].ToString());
                }
                if (row["FIsPicWaterMark"] != null && row["FIsPicWaterMark"].ToString() != "")
                {
                    model.FIsPicWaterMark = decimal.Parse(row["FIsPicWaterMark"].ToString());
                }
                if (row["FWaterMarkCls"] != null)
                {
                    model.FWaterMarkCls = row["FWaterMarkCls"].ToString();
                }
                if (row["FIsHomePageShowLimit"] != null)
                {
                    model.FIsHomePageShowLimit = row["FIsHomePageShowLimit"].ToString();
                }
                if (row["FHomePageShowDays"] != null && row["FHomePageShowDays"].ToString() != "")
                {
                    model.FHomePageShowDays = int.Parse(row["FHomePageShowDays"].ToString());
                }
                if (row["FEditMode"] != null)
                {
                    model.FEditMode = row["FEditMode"].ToString();
                }
                if (row["FDefaultEditMode"] != null)
                {
                    model.FDefaultEditMode = row["FDefaultEditMode"].ToString();
                }
                if (row["FIsNeedAudit"] != null)
                {
                    model.FIsNeedAudit = row["FIsNeedAudit"].ToString();
                }
                if (row["FIsShowHomePageCtrl"] != null)
                {
                    model.FIsShowHomePageCtrl = row["FIsShowHomePageCtrl"].ToString();
                }
                if (row["FDefaultShowValue"] != null)
                {
                    model.FDefaultShowValue = row["FDefaultShowValue"].ToString();
                }
                if (row["FIsPublicTitle"] != null)
                {
                    model.FIsPublicTitle = row["FIsPublicTitle"].ToString();
                }
                if (row["FIsCtrlLookAuthority"] != null)
                {
                    model.FIsCtrlLookAuthority = row["FIsCtrlLookAuthority"].ToString();
                }
                if (row["FIsReferenceNo"] != null)
                {
                    model.FIsReferenceNo = row["FIsReferenceNo"].ToString();
                }
                if (row["FIsNotice"] != null)
                {
                    model.FIsNotice = row["FIsNotice"].ToString();
                }
                if (row["FIsRecObject"] != null)
                {
                    model.FIsRecObject = row["FIsRecObject"].ToString();
                }
                if (row["FIsMeeting"] != null)
                {
                    model.FIsMeeting = row["FIsMeeting"].ToString();
                }
                if (row["FWaterMarkPos"] != null)
                {
                    model.FWaterMarkPos = row["FWaterMarkPos"].ToString();
                }
                if (row["FIsIndex"] != null)
                {
                    model.FIsIndex = row["FIsIndex"].ToString();
                }
                if (row["FLeftRightMargin"] != null && row["FLeftRightMargin"].ToString() != "")
                {
                    model.FLeftRightMargin = int.Parse(row["FLeftRightMargin"].ToString());
                }
                if (row["FTopBottomMargin"] != null && row["FTopBottomMargin"].ToString() != "")
                {
                    model.FTopBottomMargin = int.Parse(row["FTopBottomMargin"].ToString());
                }
                if (row["FLogoOldFileName"] != null)
                {
                    model.FLogoOldFileName = row["FLogoOldFileName"].ToString();
                }
                if (row["FLogoNewFileName"] != null)
                {
                    model.FLogoNewFileName = row["FLogoNewFileName"].ToString();
                }
                if (row["FLogoImage"] != null && row["FLogoImage"].ToString() != "")
                {
                    model.FLogoImage = (byte[])row["FLogoImage"];
                }
                if (row["FDocClsHomepage"] != null)
                {
                    model.FDocClsHomepage = row["FDocClsHomepage"].ToString();
                }
                if (row["FCreateDate"] != null && row["FCreateDate"].ToString() != "")
                {
                    model.FCreateDate = DateTime.Parse(row["FCreateDate"].ToString());
                }
                if (row["FIsImport"] != null)
                {
                    model.FIsImport = row["FIsImport"].ToString();
                }
                if (row["FSeq"] != null && row["FSeq"].ToString() != "")
                {
                    model.FSeq = int.Parse(row["FSeq"].ToString());
                }
                if (row["FIsPubJCMS"] != null)
                {
                    model.FIsPubJCMS = row["FIsPubJCMS"].ToString();
                }
                if (row["FJCMSColID"] != null && row["FJCMSColID"].ToString() != "")
                {
                    model.FJCMSColID = int.Parse(row["FJCMSColID"].ToString());
                }
                if (row["FClsTemplID"] != null && row["FClsTemplID"].ToString() != "")
                {
                    model.FClsTemplID = decimal.Parse(row["FClsTemplID"].ToString());
                }
                if (row["FTemplTopPicPath"] != null)
                {
                    model.FTemplTopPicPath = row["FTemplTopPicPath"].ToString();
                }
                if (row["FIsExamine"] != null)
                {
                    model.FIsExamine = row["FIsExamine"].ToString();
                }
                if (row["FIsManuscript"] != null)
                {
                    model.FIsManuscript = row["FIsManuscript"].ToString();
                }
                if (row.Table.Columns.Contains("FIsSpecialTopic"))
                {
                    if (row["FIsSpecialTopic"] != null)
                    {
                        model.FIsSpecialTopic = row["FIsSpecialTopic"].ToString();
                    }
                }
                if (row.Table.Columns.Contains("FIsVote"))
                {
                    model.FIsVote = row["FIsVote"].ToString();
                }
                if (row.Table.Columns.Contains("FLookAuthorityMode"))
                {
                    if (row["FLookAuthorityMode"] != null)
                    {
                        model.FLookAuthorityMode = row["FLookAuthorityMode"].ToString();
                    }
                }
            }
            return model;
        }
        /// <summary>
        /// 修改数据的同时修改权限，权限先删除除部门，岗位，工作组之外的所有相关数据在增加新数据(事务模式)
        /// <creator>wangl</creator>
        /// <date>2013-07-31</date>
        /// </summary>
        /// <param name="docClsModel">信息类别实体类</param>
        /// <param name="docClsAuthorityList">权限列表</param>
        public void UpdateDocClsandDocClsAuthority(Model.DocCls docClsModel, List<Model.DocClsAuthority> docClsAuthorityList)
        {
            List<CommandInfo> cmdList = new List<CommandInfo>();
            CommandInfo cmds = new CommandInfo();
            StringBuilder strSql = new StringBuilder();

            //更新信息
            strSql.Append("update t_docCls set ");
            strSql.Append("FDocClsProp=@FDocClsProp,");
            strSql.Append("FDocClsName=@FDocClsName,");
            strSql.Append("FIsUse=@FIsUse,");
            strSql.Append("FUseSubTitle=@FUseSubTitle,");
            strSql.Append("FIsPicNews=@FIsPicNews,");
            strSql.Append("FPicHeight=@FPicHeight,");
            strSql.Append("FPicWidth=@FPicWidth,");
            strSql.Append("FIsPicWaterMark=@FIsPicWaterMark,");
            strSql.Append("FWaterMarkCls=@FWaterMarkCls,");
            strSql.Append("FIsHomePageShowLimit=@FIsHomePageShowLimit,");
            strSql.Append("FHomePageShowDays=@FHomePageShowDays,");
            strSql.Append("FEditMode=@FEditMode,");
            strSql.Append("FDefaultEditMode=@FDefaultEditMode,");
            strSql.Append("FIsNeedAudit=@FIsNeedAudit,");
            strSql.Append("FIsShowHomePageCtrl=@FIsShowHomePageCtrl,");
            strSql.Append("FDefaultShowValue=@FDefaultShowValue,");
            strSql.Append("FIsPublicTitle=@FIsPublicTitle,");
            strSql.Append("FIsCtrlLookAuthority=@FIsCtrlLookAuthority,");
            strSql.Append("FIsReferenceNo=@FIsReferenceNo,");
            strSql.Append("FIsNotice=@FIsNotice,");
            strSql.Append("FIsRecObject=@FIsRecObject,");
            strSql.Append("FIsMeeting=@FIsMeeting,");
            strSql.Append("FWaterMarkPos=@FWaterMarkPos,");
            strSql.Append("FIsIndex=@FIsIndex,");
            strSql.Append("FLeftRightMargin=@FLeftRightMargin,");
            strSql.Append("FTopBottomMargin=@FTopBottomMargin,");
            strSql.Append("FDocClsHomepage=@FDocClsHomepage,");
            strSql.Append("FIsImport=@FIsImport,");
            strSql.Append("FIsPubJCMS=@FIsPubJCMS,");
            strSql.Append("FJCMSColID=@FJCMSColID,");
            strSql.Append("FClsTemplID=@FClsTemplID,");
            strSql.Append("FIsExamine=@FIsExamine,");
            strSql.Append("FIsManuscript=@FIsManuscript,");
            strSql.Append("FIsSpecialTopic=@FIsSpecialTopic,");
            strSql.Append("FIsVote=@FIsVote,");
            strSql.Append("FLookAuthorityMode=@FLookAuthorityMode");
            strSql.Append(" where FEntityNo=@FEntityNo and FDocClsCd=@FDocClsCd");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25),
					new SqlParameter("@FDocClsProp", SqlDbType.Char,1),
					new SqlParameter("@FDocClsName", SqlDbType.VarChar,80),
					new SqlParameter("@FIsUse", SqlDbType.Int,4),
					new SqlParameter("@FUseSubTitle", SqlDbType.Int,4),
					new SqlParameter("@FIsPicNews", SqlDbType.Decimal,5),
					new SqlParameter("@FPicHeight", SqlDbType.Int,4),
					new SqlParameter("@FPicWidth", SqlDbType.Int,4),
					new SqlParameter("@FIsPicWaterMark", SqlDbType.Decimal,5),
					new SqlParameter("@FWaterMarkCls", SqlDbType.Char,1),
					new SqlParameter("@FIsHomePageShowLimit", SqlDbType.Char,1),
					new SqlParameter("@FHomePageShowDays", SqlDbType.Int,4),
					new SqlParameter("@FEditMode", SqlDbType.Char,1),
					new SqlParameter("@FDefaultEditMode", SqlDbType.Char,1),
					new SqlParameter("@FIsNeedAudit", SqlDbType.Char,1),
					new SqlParameter("@FIsShowHomePageCtrl", SqlDbType.Char,1),
					new SqlParameter("@FDefaultShowValue", SqlDbType.VarChar,1),
					new SqlParameter("@FIsPublicTitle", SqlDbType.Char,1),
					new SqlParameter("@FIsCtrlLookAuthority", SqlDbType.Char,1),
					new SqlParameter("@FIsReferenceNo", SqlDbType.Char,1),
					new SqlParameter("@FIsNotice", SqlDbType.Char,1),
					new SqlParameter("@FIsRecObject", SqlDbType.Char,1),
					new SqlParameter("@FIsMeeting", SqlDbType.Char,1),
					new SqlParameter("@FWaterMarkPos", SqlDbType.VarChar,1),
					new SqlParameter("@FIsIndex", SqlDbType.Char,1),
					new SqlParameter("@FLeftRightMargin", SqlDbType.Int,4),
					new SqlParameter("@FTopBottomMargin", SqlDbType.Int,4),
                    new SqlParameter("@FDocClsHomepage", SqlDbType.NVarChar,255),
                    new SqlParameter("@FIsImport", SqlDbType.Char,1),
                    new SqlParameter("@FIsPubJCMS", SqlDbType.Char,1),
                    new SqlParameter("@FJCMSColID", SqlDbType.Int),
					new SqlParameter("@FClsTemplID", SqlDbType.Decimal),
                    new SqlParameter("@FIsExamine", SqlDbType.Char,1),
                    new SqlParameter("@FIsManuscript", SqlDbType.Char,1),
                    new SqlParameter("@FIsSpecialTopic", SqlDbType.Char,1),
                    new SqlParameter("@FIsVote",SqlDbType.NVarChar,1) ,
                    new SqlParameter("@FLookAuthorityMode",SqlDbType.NVarChar,1)
                                        };
            parameters[0].Value = docClsModel.FEntityNo;
            parameters[1].Value = docClsModel.FDocClsCd;
            parameters[2].Value = docClsModel.FDocClsProp;
            parameters[3].Value = docClsModel.FDocClsName;
            parameters[4].Value = docClsModel.FIsUse;
            parameters[5].Value = docClsModel.FUseSubTitle;
            parameters[6].Value = docClsModel.FIsPicNews;
            parameters[7].Value = docClsModel.FPicHeight;
            parameters[8].Value = docClsModel.FPicWidth;
            parameters[9].Value = docClsModel.FIsPicWaterMark;
            parameters[10].Value = docClsModel.FWaterMarkCls;
            parameters[11].Value = docClsModel.FIsHomePageShowLimit;
            parameters[12].Value = docClsModel.FHomePageShowDays;
            parameters[13].Value = docClsModel.FEditMode;
            parameters[14].Value = docClsModel.FDefaultEditMode;
            parameters[15].Value = docClsModel.FIsNeedAudit;
            parameters[16].Value = docClsModel.FIsShowHomePageCtrl;
            parameters[17].Value = docClsModel.FDefaultShowValue;
            parameters[18].Value = docClsModel.FIsPublicTitle;
            parameters[19].Value = docClsModel.FIsCtrlLookAuthority;
            parameters[20].Value = docClsModel.FIsReferenceNo;
            parameters[21].Value = docClsModel.FIsNotice;
            parameters[22].Value = docClsModel.FIsRecObject;
            parameters[23].Value = docClsModel.FIsMeeting;
            parameters[24].Value = docClsModel.FWaterMarkPos;
            parameters[25].Value = docClsModel.FIsIndex;
            parameters[26].Value = docClsModel.FLeftRightMargin;
            parameters[27].Value = docClsModel.FTopBottomMargin;
            parameters[28].Value = docClsModel.FDocClsHomepage;
            parameters[29].Value = docClsModel.FIsImport;
            parameters[30].Value = docClsModel.FIsPubJCMS;
            parameters[31].Value = docClsModel.FJCMSColID;
            parameters[32].Value = docClsModel.FClsTemplID;
            parameters[33].Value = docClsModel.FIsExamine;
            parameters[34].Value = docClsModel.FIsManuscript;
            parameters[35].Value = docClsModel.FIsSpecialTopic;
            parameters[36].Value = docClsModel.FIsVote;
            parameters[37].Value = docClsModel.FLookAuthorityMode;
            cmds.CommandText = strSql.ToString();
            cmds.Parameters = parameters;
            cmdList.Add(cmds);

            //先删除权限,除部门，岗位，工作组
            strSql = new StringBuilder();
            cmds = new CommandInfo();
            strSql.Append("delete from t_docClsAuthority ");
            strSql.Append(" where FEntityNo=@FEntityNo and FDocClsCd=@FDocClsCd");// and FPronoun not in('POST','GROUP','ASSIGNDEPT')");

            SqlParameter[] parameters1 ={
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25)
            };

            parameters1[0].Value = docClsModel.FEntityNo;
            parameters1[1].Value = docClsModel.FDocClsCd;

            cmds.CommandText = strSql.ToString();
            cmds.Parameters = parameters1;
            cmdList.Add(cmds);

            //增加新的权限
            if (docClsAuthorityList.Count > 0)
            {
                foreach (Model.DocClsAuthority docClsAuthorityModel in docClsAuthorityList)
                {
                    strSql = new StringBuilder();
                    cmds = new CommandInfo();

                    strSql.Append("insert into t_docClsAuthority(");
                    strSql.Append("FEntityNo,FDocClsCd,FSourceNo,FProp,FAuthorityType,FPronoun)");
                    strSql.Append(" values (");
                    strSql.Append("@FEntityNo,@FDocClsCd,@FSourceNo,@FProp,@FAuthorityType,@FPronoun)");
                    SqlParameter[] parameters2 = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25),
					new SqlParameter("@FSourceNo", SqlDbType.NVarChar,25),
					new SqlParameter("@FProp", SqlDbType.Char,1),
					new SqlParameter("@FAuthorityType", SqlDbType.NVarChar,10),
					new SqlParameter("@FPronoun", SqlDbType.NVarChar,25)};
                    parameters2[0].Value = docClsModel.FEntityNo;
                    parameters2[1].Value = docClsModel.FDocClsCd;
                    parameters2[2].Value = docClsAuthorityModel.FSourceNo;
                    parameters2[3].Value = docClsAuthorityModel.FProp;
                    parameters2[4].Value = docClsAuthorityModel.FAuthorityType;
                    parameters2[5].Value = docClsAuthorityModel.FPronoun;

                    cmds.CommandText = strSql.ToString();
                    cmds.Parameters = parameters2;
                    cmdList.Add(cmds);
                }
            }


            if (docClsModel.FIsNeedAudit == "N")//信息类别有需要审批变为不需要审批，修改未审批过的数据都已审批且都为录用
            {
                strSql = new StringBuilder();
                cmds = new CommandInfo();
                strSql.Append("update t_document set ");
                strSql.Append("FIsEnroll='Y',");
                strSql.Append("FStatus='Y'");
                strSql.Append("where FDocClsCd=@FDocClsCd and FEntityNo=@FEntityNo and FStatus='N'");
                SqlParameter[] parameters4 = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25)};
                parameters4[0].Value = docClsModel.FEntityNo;
                parameters4[1].Value = docClsModel.FDocClsCd;

                cmds.CommandText = strSql.ToString();
                cmds.Parameters = parameters4;
                cmdList.Add(cmds);

            }

            //执行存储过程，生成临时表数据，以便查询时调用 
            strSql = new StringBuilder();
            cmds = new CommandInfo();
            strSql.Append("EXEC sp_genDocAuthorityDW @EntityNo");
            SqlParameter[] parameters3 = {
					new SqlParameter("@EntityNo", SqlDbType.NVarChar,12)};
            parameters3[0].Value = docClsModel.FEntityNo;

            cmds.CommandText = strSql.ToString();
            cmds.Parameters = parameters3;
            cmdList.Add(cmds);


            DbHelperSQL.ExecuteSqlTranWithString(cmdList, 1800);
        }
        /// <summary>
        /// 更新栏目Logo相关的字段
        /// <creator>wangl</creator>
        /// <date>2013-08-02</date> 
        /// </summary>
        /// <param name="imgUrl">图片url</param>
        /// <param name="imgOldName">图片名称</param>
        /// <param name="buffer">二进制</param>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docClsCd">栏目编号</param>
        public void EditDocClsLogoImg(string imgUrl, string imgOldName, byte[] buffer, string entityNo, string docClsCd)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update t_docCls set ");
            strSql.Append("FLogoOldFileName=@FLogoOldFileName,");
            strSql.Append("FLogoNewFileName=@FLogoNewFileName,");
            strSql.Append("FLogoImage=@FLogoImage");
            strSql.Append(" where FEntityNo=@FEntityNo and FDocClsCd=@FDocClsCd");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25),					
					new SqlParameter("@FLogoOldFileName", SqlDbType.NVarChar,255),
					new SqlParameter("@FLogoNewFileName", SqlDbType.NVarChar,255),
					new SqlParameter("@FLogoImage", SqlDbType.Image)};
            parameters[0].Value = entityNo;
            parameters[1].Value = docClsCd;
            parameters[2].Value = imgOldName;
            parameters[3].Value = imgUrl;
            parameters[4].Value = buffer;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 修改页面顶部图片路径
        /// <creator>wangl</creator>
        /// <date>2013-08-02</date> 
        /// </summary>
        /// <param name="imgUrl"></param>
        /// <param name="entityNo"></param>
        /// <param name="docClsCd"></param>
        public void EditTopPicPath(string imgUrl, string entityNo, string docClsCd)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update t_docCls set ");
            strSql.Append("FTemplTopPicPath=@FTemplTopPicPath");
            strSql.Append(" where FEntityNo=@FEntityNo and FDocClsCd=@FDocClsCd");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,15),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25),					
					new SqlParameter("@FTemplTopPicPath", SqlDbType.NVarChar,255)};
            parameters[0].Value = entityNo;
            parameters[1].Value = docClsCd;
            parameters[2].Value = imgUrl;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 增加信息类别和信息类别权限(事务模式)
        /// <creator>wangl</creator>
        /// <date>2013-08-02</date> 
        /// </summary>
        /// <param name="docClsModel">信息类别实体类</param>
        /// <param name="docClsAuthorityList">信息类别权限列表</param>
        public void AddDocClsAndDocClsAuthority(Model.DocCls docClsModel, List<Model.DocClsAuthority> docClsAuthorityList)
        {
            List<CommandInfo> cmdList = new List<CommandInfo>();
            CommandInfo cmds = new CommandInfo();
            StringBuilder strSql = new StringBuilder();

            //增加信息类别
            strSql.Append("insert into t_docCls(");
            strSql.Append("FEntityNo,FDocClsCd,FPreDocClsCd,FDocClsProp,FDocClsName,FIsUse,FUseSubTitle,FIsPicNews,FPicHeight,FPicWidth,FIsPicWaterMark,FWaterMarkCls,FIsHomePageShowLimit,FHomePageShowDays,FEditMode,FDefaultEditMode,FIsNeedAudit,FIsShowHomePageCtrl,FDefaultShowValue,FIsPublicTitle,FIsCtrlLookAuthority,FIsReferenceNo,FIsNotice,FIsRecObject,FIsMeeting,FWaterMarkPos,FIsIndex,FLeftRightMargin,FTopBottomMargin,FDocClsHomepage,FIsImport,FIsPubJCMS,FJCMSColID,FClsTemplID,FIsExamine,FIsManuscript,FIsSpecialTopic,FIsVote,FLookAuthorityMode)");
            strSql.Append(" values (");
            strSql.Append("@FEntityNo,@FDocClsCd,@FPreDocClsCd,@FDocClsProp,@FDocClsName,@FIsUse,@FUseSubTitle,@FIsPicNews,@FPicHeight,@FPicWidth,@FIsPicWaterMark,@FWaterMarkCls,@FIsHomePageShowLimit,@FHomePageShowDays,@FEditMode,@FDefaultEditMode,@FIsNeedAudit,@FIsShowHomePageCtrl,@FDefaultShowValue,@FIsPublicTitle,@FIsCtrlLookAuthority,@FIsReferenceNo,@FIsNotice,@FIsRecObject,@FIsMeeting,@FWaterMarkPos,@FIsIndex,@FLeftRightMargin,@FTopBottomMargin,@FDocClsHomepage,@FIsImport,@FIsPubJCMS,@FJCMSColID,@FClsTemplID,@FIsExamine,@FIsManuscript,@FIsSpecialTopic,@FIsVote,@FLookAuthorityMode)");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25),
					new SqlParameter("@FPreDocClsCd", SqlDbType.VarChar,25),
					new SqlParameter("@FDocClsProp", SqlDbType.Char,1),
					new SqlParameter("@FDocClsName", SqlDbType.VarChar,80),
					new SqlParameter("@FIsUse", SqlDbType.Int),
					new SqlParameter("@FUseSubTitle", SqlDbType.Int),
					new SqlParameter("@FIsPicNews", SqlDbType.Decimal,5),
					new SqlParameter("@FPicHeight", SqlDbType.Int),
					new SqlParameter("@FPicWidth", SqlDbType.Int),
					new SqlParameter("@FIsPicWaterMark", SqlDbType.Decimal,5),
					new SqlParameter("@FWaterMarkCls", SqlDbType.Char,1),
					new SqlParameter("@FIsHomePageShowLimit", SqlDbType.Char,1),
					new SqlParameter("@FHomePageShowDays", SqlDbType.Int),
					new SqlParameter("@FEditMode", SqlDbType.Char,1),
					new SqlParameter("@FDefaultEditMode", SqlDbType.Char,1),
					new SqlParameter("@FIsNeedAudit", SqlDbType.Char,1),
					new SqlParameter("@FIsShowHomePageCtrl", SqlDbType.Char,1),
					new SqlParameter("@FDefaultShowValue", SqlDbType.VarChar,1),
					new SqlParameter("@FIsPublicTitle", SqlDbType.Char,1),
					new SqlParameter("@FIsCtrlLookAuthority", SqlDbType.Char,1),
					new SqlParameter("@FIsReferenceNo", SqlDbType.Char,1),
					new SqlParameter("@FIsNotice", SqlDbType.Char,1),
					new SqlParameter("@FIsRecObject", SqlDbType.Char,1),
					new SqlParameter("@FIsMeeting", SqlDbType.Char,1),
					new SqlParameter("@FWaterMarkPos", SqlDbType.VarChar,1),
					new SqlParameter("@FIsIndex", SqlDbType.Char,1),
					new SqlParameter("@FLeftRightMargin", SqlDbType.Int),
					new SqlParameter("@FTopBottomMargin", SqlDbType.Int),
                    new SqlParameter("@FDocClsHomepage", SqlDbType.NVarChar,255),
                    new SqlParameter("@FIsImport", SqlDbType.Char,1),
                    new SqlParameter("@FIsPubJCMS", SqlDbType.Char,1),
                    new SqlParameter("@FJCMSColID", SqlDbType.Int),
                    new SqlParameter("@FClsTemplID", SqlDbType.Decimal),
                    new SqlParameter("@FIsExamine", SqlDbType.Char,1),
                    new SqlParameter("@FIsManuscript", SqlDbType.Char,1),
                    new SqlParameter("@FIsSpecialTopic", SqlDbType.Char,1),
                    new SqlParameter("@FIsVote", SqlDbType.NVarChar,1),
                    new SqlParameter("@FLookAuthorityMode",SqlDbType.NVarChar,1)
                                        };
            parameters[0].Value = docClsModel.FEntityNo;
            parameters[1].Value = docClsModel.FDocClsCd;
            parameters[2].Value = PubConstant.CheckNullToDbNull(docClsModel.FPreDocClsCd);
            parameters[3].Value = docClsModel.FDocClsProp;
            parameters[4].Value = docClsModel.FDocClsName;
            parameters[5].Value = docClsModel.FIsUse;
            parameters[6].Value = docClsModel.FUseSubTitle;
            parameters[7].Value = docClsModel.FIsPicNews;
            parameters[8].Value = docClsModel.FPicHeight;
            parameters[9].Value = docClsModel.FPicWidth;
            parameters[10].Value = docClsModel.FIsPicWaterMark;
            parameters[11].Value = docClsModel.FWaterMarkCls;
            parameters[12].Value = docClsModel.FIsHomePageShowLimit;
            parameters[13].Value = docClsModel.FHomePageShowDays;
            parameters[14].Value = docClsModel.FEditMode;
            parameters[15].Value = docClsModel.FDefaultEditMode;
            parameters[16].Value = docClsModel.FIsNeedAudit;
            parameters[17].Value = docClsModel.FIsShowHomePageCtrl;
            parameters[18].Value = docClsModel.FDefaultShowValue;
            parameters[19].Value = docClsModel.FIsPublicTitle;
            parameters[20].Value = docClsModel.FIsCtrlLookAuthority;
            parameters[21].Value = docClsModel.FIsReferenceNo;
            parameters[22].Value = docClsModel.FIsNotice;
            parameters[23].Value = docClsModel.FIsRecObject;
            parameters[24].Value = docClsModel.FIsMeeting;
            parameters[25].Value = docClsModel.FWaterMarkPos;
            parameters[26].Value = docClsModel.FIsIndex;
            parameters[27].Value = docClsModel.FLeftRightMargin;
            parameters[28].Value = docClsModel.FTopBottomMargin;
            parameters[29].Value = docClsModel.FDocClsHomepage;
            parameters[30].Value = docClsModel.FIsImport;
            parameters[31].Value = docClsModel.FIsPubJCMS;
            parameters[32].Value = docClsModel.FJCMSColID;
            parameters[33].Value = docClsModel.FClsTemplID;
            parameters[34].Value = docClsModel.FIsExamine;
            parameters[35].Value = docClsModel.FIsManuscript;
            parameters[36].Value = docClsModel.FIsSpecialTopic;
            parameters[37].Value = docClsModel.FIsVote;
            parameters[38].Value = docClsModel.FLookAuthorityMode;
            cmds.CommandText = strSql.ToString();
            cmds.Parameters = parameters;
            cmdList.Add(cmds);

            //增加类别权限
            if (docClsAuthorityList.Count > 0)
            {
                foreach (Model.DocClsAuthority docclsAuthor in docClsAuthorityList)
                {
                    strSql = new StringBuilder();
                    cmds = new CommandInfo();

                    strSql.Append("insert into t_docClsAuthority(");
                    strSql.Append("FEntityNo,FDocClsCd,FSourceNo,FProp,FAuthorityType,FPronoun)");
                    strSql.Append(" values (");
                    strSql.Append("@FEntityNo,@FDocClsCd,@FSourceNo,@FProp,@FAuthorityType,@FPronoun)");
                    SqlParameter[] parameters1 = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25),
					new SqlParameter("@FSourceNo", SqlDbType.NVarChar,25),
					new SqlParameter("@FProp", SqlDbType.Char,1),
					new SqlParameter("@FAuthorityType", SqlDbType.NVarChar,10),
					new SqlParameter("@FPronoun", SqlDbType.NVarChar,25)};
                    parameters1[0].Value = docclsAuthor.FEntityNo;
                    parameters1[1].Value = docClsModel.FDocClsCd;
                    parameters1[2].Value = docclsAuthor.FSourceNo;
                    parameters1[3].Value = docclsAuthor.FProp;
                    parameters1[4].Value = docclsAuthor.FAuthorityType;
                    parameters1[5].Value = docclsAuthor.FPronoun;

                    cmds.CommandText = strSql.ToString();
                    cmds.Parameters = parameters1;
                    cmdList.Add(cmds);
                }
            }

            //执行存储过程，生成临时表数据，以便查询时调用 
            strSql = new StringBuilder();
            cmds = new CommandInfo();
            strSql.Append("EXEC sp_genDocAuthorityDW @EntityNo");
            SqlParameter[] parameters2 = {
					new SqlParameter("@EntityNo", SqlDbType.NVarChar,12)};
            parameters2[0].Value = docClsModel.FEntityNo;

            cmds.CommandText = strSql.ToString();
            cmds.Parameters = parameters2;
            cmdList.Add(cmds);

            DbHelperSQL.ExecuteSqlTranWithString(cmdList, 1800);

        }
        /// <summary>
        /// 删除信息类别和信息类别权限(事务模式)
        /// <creator>wangl</creator>
        /// <date>2013-08-02</date> 
        /// </summary>
        /// <param name="entityNo">公司编码</param>
        /// <param name="docClsCd">信息类别编码</param>
        /// <param name="isSingleDoc">是否是单信息</param>
        public void DeleteDocClsAndDocClsAuthority(string entityNo, string docClsCd, bool isSingleDoc)
        {
            List<CommandInfo> cmdList = new List<CommandInfo>();
            CommandInfo cmds = new CommandInfo();
            StringBuilder strSql = new StringBuilder();

            //删除信息类别
            strSql.Append("delete from t_docCls ");
            strSql.Append(" where FEntityNo=@FEntityNo and FDocClsCd=@FDocClsCd");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,50),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,50)};
            parameters[0].Value = entityNo;
            parameters[1].Value = docClsCd;

            cmds.CommandText = strSql.ToString();
            cmds.Parameters = parameters;
            cmdList.Add(cmds);

            //删除权限
            strSql = new StringBuilder();
            cmds = new CommandInfo();

            strSql.Append("delete from t_docClsAuthority ");
            strSql.Append(" where FEntityNo=@FEntityNo and FDocClsCd=@FDocClsCd");
            SqlParameter[] parameters1 = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25)};
            parameters1[0].Value = entityNo;
            parameters1[1].Value = docClsCd;

            cmds.CommandText = strSql.ToString();
            cmds.Parameters = parameters1;
            cmdList.Add(cmds);

            //如果是单信息，删除信息数据
            if (isSingleDoc)
            {
                strSql = new StringBuilder();
                cmds = new CommandInfo();
                strSql.Append("delete from t_document ");
                strSql.Append(" where FDocClsCd=@FDocClsCd and FEntityNo=@FEntityNo");
                SqlParameter[] parameters6 = {
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,50),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,50)};
                parameters6[0].Value = entityNo;
                parameters6[1].Value = docClsCd;

                cmds.CommandText = strSql.ToString();
                cmds.Parameters = parameters6;
                cmdList.Add(cmds);
            }


            //执行存储过程，生成临时表数据，以便查询时调用 
            strSql = new StringBuilder();
            cmds = new CommandInfo();
            strSql.Append("EXEC sp_genDocAuthorityDW @EntityNo");
            SqlParameter[] parameters3 = {
					new SqlParameter("@EntityNo", SqlDbType.NVarChar,12)};
            parameters3[0].Value = entityNo;

            cmds.CommandText = strSql.ToString();
            cmds.Parameters = parameters3;
            cmdList.Add(cmds);


            DbHelperSQL.ExecuteSqlTranWithString(cmdList, 1800);
        }
        /// <summary>
        /// 是否存在该记录
        /// <creator>wangl</creator>
        /// <date>2013-08-02</date> 
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docClsCd">信息类别</param>
        /// <returns>true-存在 false-不存在</returns>
        public bool Exists(string entityNo, string docClsCd)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from t_docCls");
            strSql.Append(" where FEntityNo=@FEntityNo and FDocClsCd=@FDocClsCd and FIsUse=1");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,50),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,50)};
            parameters[0].Value = entityNo;
            parameters[1].Value = docClsCd;

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 获得数据列表,根据公司编号和上级编号
        /// <creator>wangl</creator>
        /// <date>2013-08-02</date> 
        /// </summary>
        public DataSet GetListByEntityNoAndPreDocClsNo(string entityNo, string preDocClsNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * FROM t_docCls");
            strSql.Append(" where FEntityNo=@FEntityNo and FIsUse=1");
            int t = 0;
            if (preDocClsNo != "")
            {
                strSql.Append(" and FPreDocClsCd=@FPreDocClsCd");
                t = 1;
            }
            else
            {
                strSql.Append(" and FPreDocClsCd is null");
            }

            strSql.Append(" order by FSeq,FDocClsCd");

            if (t == 1)
            {
                SqlParameter[] parameters = { 
                     new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
                     new SqlParameter("@FPreDocClsCd", SqlDbType.VarChar,50)};
                parameters[0].Value = entityNo;
                parameters[1].Value = preDocClsNo;

                return DbHelperSQL.Query(strSql.ToString(), parameters);
            }
            else
            {

                SqlParameter[] parameters = { 
                 new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)};
                parameters[0].Value = entityNo;

                return DbHelperSQL.Query(strSql.ToString(), parameters);
            }
        }
        /// <summary>
        /// 信息类别排序
        /// <creator>wangl</creator>
        /// <date>2013-08-02</date> 
        /// </summary>
        /// <param name="docClsCds">信息类别编号集合</param>
        /// <param name="entityNo">公司编号</param>
        public void SeqDocClsTop(string[] docClsCds, string entityNo)
        {
            List<CommandInfo> cmdList = new List<CommandInfo>();
            CommandInfo cmds;
            StringBuilder strSql;
            int intTopSeq = 0;
            foreach (string docClsCd in docClsCds)
            {
                intTopSeq++;
                cmds = new CommandInfo();
                strSql = new StringBuilder();
                strSql.Append("update t_docCls set FSeq=@FSeq where FDocClsCd=@FDocClsCd and FEntityNo=@FEntityNo");

                SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25),					
					new SqlParameter("@FSeq", SqlDbType.Int,4)};

                parameters[0].Value = entityNo;
                parameters[1].Value = docClsCd;
                parameters[2].Value = intTopSeq;

                cmds.CommandText = strSql.ToString();
                cmds.Parameters = parameters;
                cmdList.Add(cmds);
            }

            DbHelperSQL.ExecuteSqlTranWithString(cmdList);
        }
        /// <summary>
        /// 根据编号，获取其父类编号和其组成的路径 01/02/03
        /// <creator>wangl</creator>
        /// <date>2013-08-13</date> 
        /// </summary>
        /// <param name="docClsCd">信息类别编号</param>
        /// <param name="entityNo">公司编号</param>
        /// <returns></returns>
        public string GetDocClsCdS(string docClsCd, string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select dbo.fn_getDocClsNoS(@FDocClsCd,@FEntityNo)");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
                    new SqlParameter("@FDocClsCd", SqlDbType.VarChar,25)};
            parameters[0].Value = entityNo;
            parameters[1].Value = docClsCd;
            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters))
            {
                if (sdr.Read())
                {
                    return sdr[0].ToString();
                }
            }
            return docClsCd;
        }
        /// <summary>
        /// 获取信息类别名称路径名
        /// <creator>wangl</creator>
        /// <date>2013-08-14</date> 
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docClsCd">信息类别编号</param>
        /// <returns>名称路径名</returns>
        public string GetDocClsPathNames(string entityNo, string docClsCd)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select dbo.fn_getDocClsNames(@FDocClsCd,@FEntityNo)");
            SqlParameter[] parameters = {
					new SqlParameter("@FDocClsCd", SqlDbType.VarChar,50),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,50)};
            parameters[0].Value = docClsCd;
            parameters[1].Value = entityNo;
            using (SqlDataReader sda = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters))
            {
                if (sda.Read())
                {
                    return sda[0].ToString();
                }
            }

            return "";
        }

        /// <summary>
        /// 获取信息类别数据，根据信息考核分中定义的需要考试的类别ID和相关年数 获取字段：FDocClsCd,fdocclsname,fpredocclscd
        /// <creator>sunlj</creator>
        /// <date>2013-10-16</date>
        /// </summary>
        /// <param name="strEntityNo">单位编号</param>
        /// <param name="strYear">年份</param>
        /// <returns></returns>
        public DataSet getDocClsByScore(string strEntityNo, decimal strYear)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(" select FDocClsCd,fdocclsname,fpredocclscd from t_docCls where FIsUse='1' AND FEntityNo=@FEntityNo and fDocClsCd in(select FDocClsCd from t_docClsScore where FEntityNo=@FEntityNo and FYear=@FYear and FIsScore=1)");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,50),
					new SqlParameter("@FYear", SqlDbType.Decimal,5)};

            parameters[0].Value = strEntityNo;
            parameters[1].Value = strYear;

            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 获取专题专栏（已启用）
        /// <creator>wangl</creator>
        /// <date>2013-10-30</date>
        /// </summary>
        /// <param name="preDocClsID"></param>
        /// <param name="entityNo"></param>
        /// <param name="top"></param>
        /// <returns></returns>
        public DataSet GetIdAndLogUrl(string preDocClsID, string entityNo, int top = 0)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select");
            if (top > 0)
            {
                strSql.Append(" top ");
                strSql.Append(top);
            }
            strSql.Append(" FDocClsCd,FLogoNewFileName from t_docCls");
            strSql.Append(" where FIsUse='1' and  FPreDocClsCd=@FPreDocClsCd and FEntityNo=@FEntityNo order by FSeq, FDocClsCd");

            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,15),
					new SqlParameter("@FPreDocClsCd", SqlDbType.VarChar,25)	};
            parameters[0].Value = entityNo;
            parameters[1].Value = preDocClsID;

            return DbHelperSQL.Query(strSql.ToString(), parameters);

        }



    }
}
